package com.atguigu.lease.web.admin.mapper;

import com.atguigu.lease.model.entity.ApartmentInfo;
import com.atguigu.lease.web.admin.vo.apartment.ApartmentItemVo;
import com.atguigu.lease.web.admin.vo.apartment.ApartmentQueryVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Select;

/**
* @author liubo
* @description 针对表【apartment_info(公寓信息表)】的数据库操作Mapper
* @createDate 2023-07-24 15:48:00
* @Entity com.atguigu.lease.model.ApartmentInfo
*/
public interface ApartmentInfoMapper extends BaseMapper<ApartmentInfo> {

    IPage<ApartmentItemVo> listApartments(IPage<ApartmentItemVo> page, ApartmentQueryVo queryVo);

    @Select("select id, name, introduction, district_id, district_name, city_id, city_name, province_id, province_name, address_detail, latitude, longitude, phone, is_release from apartment_info ai where ai.id=(" +
            "select apartment_id from room_info ri where ri.is_deleted=0 and ri.is_release=1 and ri.id =#{id}) and ai.is_deleted=0 and ai.is_release=1")
    ApartmentInfo queryApartmentByRoomId(Long id);
}




